import React, { Component } from 'react'
import PubSub from 'pubsub-js'
// 哪个组件要接收数据,就使用context.Consumer
export default class Son extends Component {
  componentDidMount() {
    PubSub.subscribe('car', (topic, data) => {
      console.log(data)
    })
  }
  render() {
    return (
      <div>
        <h1>Son</h1>
        <button
          onClick={() => {
            PubSub.publish('howFindMoney', '没希望,不可能')
          }}
        >
          发布找富婆
        </button>
      </div>
    )
  }
}
